/*******************************************************************************
 * Copyright (c) 2013 Michele Nanna.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Michele Nanna - initial API and implementation
 ******************************************************************************/
package com.systemfastforward.provinciawifi.service;

import java.io.IOException;
import java.net.URL;

import nl.matshofman.saxrssreader.RssFeed;
import nl.matshofman.saxrssreader.RssReader;

import org.xml.sax.SAXException;

import android.os.AsyncTask;
import android.util.Log;

public class DownloadRssFeedTask extends AsyncTask<String, Void, RssFeed> {
	private static final String LOG_TAG = DownloadRssFeedTask.class.getSimpleName();
	
	@Override
	protected RssFeed doInBackground(String... params) {
		try {
			URL url = new URL(params[0]);
			return RssReader.read(url);
		} catch (SAXException e) {
			Log.i(LOG_TAG, "Error parsing RSS Feed: " + e.getLocalizedMessage());
		} catch (IOException e) {
			Log.i(LOG_TAG, "Error reading RSS Feed from web: " + e.getLocalizedMessage());
		}
		return null;
	}

	@Override
	protected void onPostExecute(RssFeed feed) {
		super.onPostExecute(feed);
	}
}
